﻿using System;
using System.Collections.Generic;

using E.Enum;
using E.Web.UI.Page;
using E.Web.Common;

using X.Common;

namespace E.Web.training.frames
{
    public partial class Menu : BasePage
    {
        public System.Text.StringBuilder sb;

        protected override void ShowPage()
        {
            IList<MenuModel> menu = WebCommon.GetUserMenu(authority);
            sb = new System.Text.StringBuilder();

            if (menu.Count > 0)
            {
                sb.Append("<div id=\"menu\">\r\n");
                sb.Append("  <ul>\r\n");
                //sb.Append( GetMenuContent();

                int i = 0;
                foreach (MenuModel model in menu)
                {
                    sb.Append("<li id=\"m_" + i + "\">\r\n");
                    sb.Append("  <div class=\"root\">\r\n");
                    sb.Append("    <div class=\"m_r\">\r\n");
                    sb.Append("      <div><a href=\"" + model.RootLink + "\" onclick=\"ShowSub(" + i + ");\">" + model.RootTitle + "</a></div>\r\n");
                    sb.Append("      <img id=\"m_img_" + i + "\" alt=\"\" src=\"/images/training/icon/arrow_right.gif\" class=\"cursor\" onclick=\"ShowSub(" + i + ");\" />\r\n");
                    sb.Append("    </div>\r\n");
                    sb.Append("  </div>\r\n");
                    sb.Append("  <div id=\"sub_" + i + "\" class=\"sub\" style=\"display:none;\">\r\n");
                    sb.Append("    <ul>\r\n");

                    for (var j = 0; j < model.SubTitle.Length; j++)
                    {
                        sb.Append("      <li id=\"sub_" + i + "_" + j + "\"><a href=\"" + model.SubLink[j] + "\" target=\"managerFrame\" id=\"subHref_" + i + "_" + j + "\" onclick=\"SetCurrentLinkColor(" + i + "," + j + ");\">" + model.SubTitle[j] + "</a></li>\r\n");
                    }

                    sb.Append("    </ul>\r\n");
                    sb.Append("<input type=\"hidden\" id=\"len_" + i + "\" name=\"len_" + i + "\" value=\"" + model.SubTitle.Length + "\" />");
                    sb.Append("  </div>\r\n");
                    sb.Append("</li>\r\n");
                    i++;
                }

                sb.Append("  </ul>\r\n");
                sb.Append("<input type=\"hidden\" id=\"len\" name=\"len\" value=\"" + i + "\" />");
                sb.Append("</div>\r\n");
            }
        }



        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}
